package edu.sctu.zcy.month201505.day20150524;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;

/**
 * Created by user24 on 2015/5/24.
 */
public class VectorDemo {

    public static void main(String[] args) {

        Vector vector = new Vector();

        for (int i = 0; i < 11; i++) {

            vector.add("内容"+i);
        }

        System.out.println("集合的总数:"+vector.size());

        System.out.println(vector);

        Enumeration enumeration = vector.elements();

        while (enumeration.hasMoreElements()){
            System.out.print(enumeration.nextElement() + "  \n");
        }

        Iterator iterator = vector.iterator();

        while (iterator.hasNext()){
            System.out.print(iterator.next() + "  ");
        }

        vector.set(9,"内容10（更新）");

        System.out.println("10"+vector.get(9));

        System.out.println(vector);

        String s = "内容6";

        int a = vector.indexOf(s);

        if(a > -1){
            System.out.println("集合包括（"+s+")元素，位置为："+(a+1));
        }

    }
}
